home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Mac OS Development Toolkit / Automation Essentials 2.3.0 / Host Automation Folder / SPEC Libs / DA.Lib < prev    next >
Encoding:
Text File  |  1998-03-19  |  8.4 KB  |  213 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:        DA.Lib
  5. #
  6. #    Contains:    xxx put contents here xxx
  7. #
  8. #    Written by:    KTA, KL, ML, GS et al
  9. #
  10. #    Copyright:    © 1993-1995 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #    <1.0.13>    11/15/95    ML        Scrapbook - revise call to LaunchTwitch to         launch the
  19. #                                    scrapbook.
  20. #    1.0.12+>    11/15/95    ML        Scrapbook - revise call to LaunchTwitch to launch the scrapbook.
  21. #    <1.0.12>     1/19/95    KTA        Changed the name of ExceptionHandler() to ExceptionDispatcher().
  22. #    <1.0.11>     12/7/94    ML        Added Exception Handling support
  23. #    1.0.10+>     12/6/94    ML        Added Exception Handling support
  24. #    <1.0.10>     4/28/94    KTA        Scrapbook() - Don't profile Application when twitching back to
  25. #                                    app from scrapbook.
  26. #    <1.0.8+>    11/19/93    NAGA        modify TCS format
  27. #     <1.0.8>     9/23/93    KTA        ScrapBook() -Changed calls to launchTwitch so they twitch but do
  28. #                                    not launch the previousApp.
  29. #     <1.0.7>     8/25/93    KTA        Added support for parity checking the TCS stack.
  30. #     <1.0.6>      8/4/93    KTA        ScrapBook() - Match of the window wasn't using gScrapTitle.
  31. #     <1.0.5>     7/30/93    KTA        ScrapBook() - updates so when scrapbook doesn't have enough
  32. #                                    memory to launch it will be handled as expected failure.
  33. #     <1.0.4>     7/14/93    KTA        Changes for international support
  34. #     <1.0.3>      7/6/93    KTA        Change a couple of Println's to LogStr's
  35. #        <1+>     5/21/93    NAGA        Adding header and porting old files to follow new standards
  36. #
  37. # ****************************************************************************
  38. #
  39.  
  40. ########################################################################
  41. #                            External libraries 
  42. #=======================================================================
  43. Libraries "Output.Lib","TCS.Lib","LaunchQuit.Lib","TargetCheck.Lib",
  44. "UserInterface.Lib", "ExceptionHandling.Lib";
  45.  
  46. #########################################################################
  47. #                Scrapbook(requestElement,ccpFlag,pasteFlag)
  48. #========================================================================
  49. # Author:        KTA
  50. # Description:    This routine will select the scrapbook, scroll to the
  51. #                designated requestElement position, select Cut, Copy, Paste,
  52. #                or Clear from the Edit menu, close the scrapbook if under System
  53. #                6.0.x, and then select Paste if the pasteFlag parameter is 1.
  54. # Parameters:    requestElement - the element in the scrapbook to scroll to
  55. #                ccpFlag -    1 for copy
  56. #                            2 for cut
  57. #                            3 for paste
  58. #                            4 for clear
  59. #                pasteFlag - 1 to paste after closing Scrapbook
  60. #                            0 not to paste after closing Scrapbook
  61. # Returns:        0 - Couldn't complete operation
  62. #                element - Scrapbook element that operation took place on
  63. # Examples:        Scrapbook(2) will scroll the horizontal bar to the
  64. #                second entry and then copy, close and paste.
  65. # Assumptions:    That the scrollbars are present. That the string
  66. #                'Scrapbook' appear somewhere in the name
  67. #========================================================================
  68. # History:
  69. # KTA    7/7/93    Made the title of the scrapbook a global, changed references to it.
  70. #                 changed cut, copy, paste, clear to be referenced by ordinality
  71. #                final paste into app is KeyEq('v'); (all changes to support intl)
  72. # KTA    8/4/93    Match of the window wasn't using gScrapTitle
  73. # KTA    8/24/93    TCS stack parity check
  74. # KTA    9/23/93    Changed calls to launchTwitch so they twitch but do not launch the previousApp.
  75. # KTA    4/28/94    Don't profile Application when twitching back to app from scrapbook 
  76. #                even if gAdditionalTargetInfo is true.
  77. # ML    11/29/94    Added Exception Handling support
  78. # ML    11/15/95    call to LaunchTwitch needs to launch scrapbook
  79. #########################################################################
  80. TASK Scrapbook(requestElement,ccpFlag := 1,pasteFlag := 1) 
  81. begin
  82.     Global gPrevAppTitle,gIntegration,kScrapTEXT,kScrapPICT,gAppTitle, gScrapTitle;
  83.     temp := gIntegration;    
  84.     Integration := 0;            #To turn off global Integration - KTA
  85.     tempgBackgroundQuit:= global gBackgroundQuit;
  86.     gBackgroundQuit:= 0;
  87.     tempgForceQuit:= global gForceQuit;
  88.     gForceQuit:= 0;
  89.     tempgFillMemory:= global gFillMemory;
  90.     gFillMemory:= 0;
  91.     LogStr( "==========================================================");
  92.     LogStr("Performing Scrapbook DA test.");
  93.     returnval:=0;
  94.     failStr := '';
  95.     ScrapDescriptor := '';    
  96.     if(requestElement = kScrapPICT)
  97.         TCSNUM := 1;
  98.     else if(requestElement = kScrapTEXT)
  99.         TCSNUM := 2;
  100.     else
  101.         TCSNUM := 3;
  102.     
  103.     TCSStart({ TCSNUM, global kTCSetScrapBook }, 'ScrapBook');
  104.     if not(gAppTitle)
  105.         MatchApplication(0);
  106.     If(LaunchTwitch(gScrapTitle,,,0))
  107.     begin
  108.         LogStr("Opened the Scrapbook");
  109.         scBook := _match ([window t:gScrapTitle o:1]!,1);
  110.         if(scBook.k[1].t = 'Play Sound') #put in fix for 7.0ß4 where sound button is control [1]
  111.             SkrollBar := scBook.k[2];
  112.         else
  113.             SkrollBar := scBook.k[1];
  114.         status := SkrollBar.s;
  115.         if (status <> { 0, -1 })
  116.         begin                                        # if scrollbar is enabled...
  117.             error := 0;                                # no errors yet
  118.             elementCount := status[2] + 1;            # elementCount = number of scrapbook elements
  119.             currentElement := status[1] + 1;        # currentElement = current position in Scrapbook
  120.             newCount := elementCount + 1;
  121.     
  122.             if (requestElement>elementCount) begin    # if position is greater than total elements in Scrapbook.. 
  123.                 if (ccpFlag = 1)
  124.                     LogStr("!@#$% Scrapbook entry {requestElement} does not exist! - Copying entry {currentElement} of {elementCount}");
  125.                 else if (ccpFlag = 3)
  126.                     LogStr("!@#$% Scrapbook entry {requestElement} does not exist! - Pasting to entry {currentElement} of {newCount}");
  127.                 else begin
  128.                     LogStr("!@#$% Can∂'t Cut/Clear - Scrapbook entry {requestElement} does not exist! Closing Scrapbook!");
  129.                     error := 1;    # don't clear or cut if requested item not there
  130.                 end;
  131.             end;
  132.             else begin# we've got a valid Scrapbook entry
  133.                 _scroll (SkrollBar, 'a', {requestElement,elementCount});
  134.                 try match [scrollbar s:?status]!;
  135.                 catch theError
  136.                     ExceptionDispatcher(theError);
  137.                 currentElement := status[1] + 1;        # currentElement = current position in Scrapbook
  138.                 LogStr("Scrolled to item {currentElement} of {elementCount} of the ScrapBook");
  139.                 wait(1);
  140.             end;
  141.             
  142.             if (not error) begin
  143.                 if (ccpFlag = 1) begin    # Copy Item
  144.                     if not( SelectMenuItem(4, 3))    # error - couldn't copy
  145.                         error := 1;        # prepare to abort
  146.                 end;
  147.                 else if (ccpFlag = 2)  begin
  148.                     if (not SelectMenuItem(3, 3))    # error - couldn't cut    
  149.                         error := 1;        # prepare to abort
  150.                 end;
  151.                 else if (ccpFlag = 3)  begin
  152.                     if (not SelectMenuItem(5, 3))    # error - couldn't cut    
  153.                         error := 1;        # prepare to abort
  154.                     else
  155.                         LogStr("Pasted to entry {currentElement} of {newCount}");                        
  156.                 end;
  157.                 else if (ccpFlag = 4)  begin
  158.                     if (not SelectMenuItem(6, 3))    # error - couldn't clear    
  159.                         error := 1;        # prepare to abort
  160.                 end;
  161.             end;
  162.             wait(2);
  163.             tempTargetInfo := global gAdditionalTargetInfo;
  164.             global gAdditionalTargetInfo := 0;
  165.             LaunchTwitch(gPrevAppTitle,,0);        # Twitch to it but don't launch it
  166.             global gAdditionalTargetInfo := tempTargetInfo;
  167.  
  168.             if not (error)
  169.             begin
  170.                 if (pasteFlag)    begin    # if we're supposed to paste back into document, do it
  171.                     wait(3);
  172.                     if (keyEq('v'))
  173.                     begin
  174.                         LogStr("==========================================================");
  175.                         returnval:=1;
  176.                     end;
  177.                 end;
  178.                 returnval:= currentElement;    # everything went OK
  179.             end; # if not (error)
  180.         end; # if scrollbar is enabled...
  181.         else begin
  182.             failStr := '!@#$% The horizontal scroll bar was not enabled to scroll';
  183.             LogStr(failStr);
  184.             closeWindow();
  185.         end;
  186.     end; # If(LaunchTwitch('Scrapbook'))
  187.     else begin
  188.         scrapReturn := -1;        # couldn't launch is an expected failure
  189.         LaunchTwitch(gPrevAppTitle,,0);        # Twitch to it but don't launch it
  190.         failStr := "Couldn't launch the Scrapbook";
  191.     end;
  192.  
  193.     if (returnVal)    # Return pass or fail
  194.     begin
  195.         ScrapReturn := 1;
  196.         ScrapDescriptor := returnVal;
  197.     end;
  198.     else
  199.     begin
  200.         if not(scrapReturn = -1)    # Couldn't launch
  201.             ScrapReturn := 0;
  202.     end;
  203.     
  204.     TCSEnd({ TCSNUM, global kTCSetScrapBook }, ScrapReturn,failStr,,ScrapDescriptor);            # End TCS
  205.     gBackgroundQuit:= tempgBackgroundQuit;
  206.     gForceQuit:= tempgForceQuit;
  207.     gFillMemory:= tempgFillMemory;
  208.     gIntegration := temp;            #To reset the integration global - KTA
  209.     
  210.     return(returnval);
  211.  
  212. end; # Scrapbook()
  213.